package com.common.utils;

import com.common.cons.Constans;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * Created by chen on 2018/4/4.
 */

public class SortUtils {
    public static String[] getStringGroup(String... items){
        ArrayList tempList  = new ArrayList();
      
        for (String i : items){
            tempList.add(i); 
        }
        return  (String[])tempList.toArray(new String[tempList.size()]); 
    }
    public static String  getFinalString(String[] group){
        Arrays.sort(group);
        String s = Arrays.toString(group).replace("[","").replace("]","").replace(",","").replace(" ","")+ Constans.ANDROID_APP_KEY;
        System.out.println("hah"+s);
        return s ;
        
    } 
    public static String getHash(String... items){
        String finalString = getFinalString(getStringGroup(items));
        return MD5Utils.MD5Encode(finalString);
    }
    public static String getMyHash(String... args) {
        List<String> list = new ArrayList<>();
        list.add("time");
        list.add("apiId");
        list.add("terminal");
            for(String arg : args){
                list.add(arg);
            }
        Collections.sort(list);
        int j;
        String string = "";
        for (j = 0; j < list.size(); j++) {
            string += list.get(j);
        }
        System.out.println("带下划线的"+string);
        return MD5Utils.MD5Encode(string+"1db10c97c2e2bc080f6b015f852b1115");
    }

}
